const { ccclass, property } = cc._decorator;
declare let i18n,DBManager,dbh;
import BaseView from "../../component/BaseView";
import UIHelper = require("../../component/UIHelper");
import PopUIHelper = require("../../utils/PopUIHelper");
import Utils = require("../../utils/Utils");
//找不同 关卡14
@ccclass
export default class DeputyFindDiffView extends BaseView {
    @property(cc.Label)
    lblStep: cc.Label = null;
    @property(cc.Label)
    lblDes: cc.Label = null;
    @property(cc.Node)
    quanNode: cc.Node[] = [];

    //恭喜获得
    @property(cc.Node)
    endNode: cc.Node = null;

    _quan0 = false;
    _quan1 = false;
    _quan2 = false;
    _isDone = false;
    _isStart = false;
    onLoad() {
        Utils.audioManager.playBGM("huazhuang/deputyGame/deputyGameBg");
        //@ts-ignore
        this._isStart = this.node.openParam;
        this.lblStep.string = i18n.t("DEPUTY_GAME_STEP_TITLE14");
        this.lblDes.string = i18n.t("DEPUTY_GAME_STEP_DES14");
    };
    onClose(){
        Utils.audioManager.playDefaultBGM();
    };
    onClickFind(event,index){
        if(this._isDone)
            return;
        let _index = parseInt(index);
        let node = this.quanNode[_index];
        if(node && node.active == false){
            node.active = true;
            if(_index == 0){
                this._quan0 = true;
            }else if(_index == 1){
                this._quan1 = true;
            }else if(_index == 2){
                this._quan2 = true;
            }
        }
        if(this._quan0 == true && this._quan1 == true && this._quan2 == true){
            this._isDone = true;
            this.endNode.active = true;
            Utils.audioManager.playSound("huazhuang/deputyGame/pass");
        }
    };

    onClickEnd(isSkip){
        let next = this.params.next && this.params.next.shift();
        if (next) {
            UIHelper.openUI(next, {
                next: this.params.next
            })
            this.node.destroy();
        }
    };
    
    onClickSkip(){
        this.onClickEnd(true);
    };

    //提示
    onClickTips(){
        PopUIHelper.helper.showNewConfirmMsg(i18n.t("DEPUTY_GAME_TIPS14"));
    };
    
    
}
